<template>
  <el-col v-bind='baseColProps' :span='colSize'>
    <div class="co-form-action__btns f-right">
      <slot name="submitBefore"></slot>
      <el-button v-if="showResetButton" v-bind="getResetBtnOptions" type="primary" @click="searchForm">搜索</el-button>
      <el-button v-if="showSubmitButton" v-bind="getSubmitBtnOptions" @click="resetForm" class="c-button__default">重置</el-button>
      <slot name="resetAfter"></slot>
      <el-button v-if="showExportButton || hasExportPermission()" v-bind="exportButtonOptions" @click="exportFile" class="td-button--primary" type="primary">导出</el-button>
      <slot name="exportAfter"></slot>
    </div>
  </el-col>
</template>

<script>
export default {
  props: {
    schema: {
      type: Object,
      default: () => {}
    },
    baseColProps: {
      type: [Object, Number]
    },
    // 显示重置按钮
    showResetButton: {
      type: Boolean
    },
    showSubmitButton: {
      type: Boolean
    },
    resetButtonOptions: {
      type: Object
    },
    submitButtonOptions: {
      type: Object
    },
    showExportButton: {
      type: Boolean
    },
    exportButtonOptions: {
      type: Object
    },
    colSize: {
      type: Number,
      default: 8
    },
    // 是否有导出权限
    hasExportPermission: {
      type: Function,
      default: () => {
        return false
      }
    }
  },
  computed: {
    getResetBtnOptions () {
      return this.resetButtonOptions
    },
    getSubmitBtnOptions () {
      return this.submitButtonOptions
    }
  },
  data () {
    return {

    }
  },
  created () {

  },
  mounted () {

  },
  methods: {
    searchForm () {
      this.$listeners.searchForm()
    },
    resetForm () {
      this.$listeners.resetForm()
    },
    exportFile () {
      this.$listeners.exportFile()
    }
  }
}
</script>
<style lang="scss">
.co-form-action__btns {
  .el-button {
    width: 100px;
  }
}
</style>
